combit List & Label 30 - .NET Help
Programming Introduction / Examples / General / Extend Designer by Custom Function
Extend Designer by Custom Function

The following example shows how a function can be added that allows querying a registry key within a report. The result of the function could be used in appearance conditions for objects for example. Of course the properties of the DesignerFunction class can also be set directly in the properties window of the development environment.

using (ListLabel LL = new ListLabel())
{
    // Define/Assign data source
    LL.DataSource = CreateDataSet();

                
    // Initialize function
    DesignerFunction RegQuery = new DesignerFunction();
    RegQuery.FunctionName = "RegQuery";
    RegQuery.GroupName = "Registry";
    RegQuery.MinimalParameters = 1;
    RegQuery.MaximumParameters = 1;
    RegQuery.ResultType = LlParamType.String;
    RegQuery.EvaluateFunction += new EvaluateFunctionHandler(RegQuery_EvaluateFunction);

    // Add function
    LL.DesignerFunctions.Add(RegQuery);

    // Call the designer
    LL.Design();
}

// ...

void RegQuery_EvaluateFunction(object sender, EvaluateFunctionEventArgs e)
{
    // Get registry key
    RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\combit\");
    e.ResultValue = key.GetValue(e.Parameter1.ToString()).ToString();
}